﻿using UnityEngine;

[RequireComponent(typeof(Rigidbody2D), typeof(Animator))]
public class Spaceship : MonoBehaviour
{
	// 移动速度
	public float speed;
	
	// 攻击间隔
	public float shotDelay;
	
	// 子弹预制件对象
	public GameObject bullet;
	
	// 能否射击
	public bool canShot;
	
	// 爆炸特效
	public GameObject explosion;

	// 动画控制
	private Animator animator;

	void Start ()
	{
		// 获取动画组件
		animator = GetComponent<Animator> ();
	}

	// 生成爆炸组件
	public void Explosion ()
	{
		Instantiate (explosion, transform.position, transform.rotation);
	}
	
	// 生成子弹
	public void Shot (Transform origin)
	{
		Instantiate (bullet, origin.position, origin.rotation);
	}

	// 外部获取动画
	public Animator GetAnimator()
	{
		return animator;
	}
}